/*
 * @Author: 鱿鱼溪学院
 * @Date: 2024-09-16 02:57:28
 * @LastEditTime: 2024-09-16 18:38:31
 * @LastEditors: 鱿鱼溪学院
 * @Description:
 * @FilePath: \yyx_admin\src\utils\auth.ts
 * Copyright 鱿鱼溪学院 by edu v1.0
 * 天道酬勤
 */

import { TIME_STAMP, TOKEN_TIME_VALUE } from '@/constant'
import { getItem, setItem } from './storage'

/**
 * @description:获取时间戳
 * @return {*}
 */
export function getTimeStamp() {
  return getItem(TIME_STAMP)
}

/**
 * @description: 设置时间戳
 * @return {*}
 */
export function setTimeStamp() {
  setItem(TIME_STAMP, Date.now())
}

/**
 * @description: 是否超时
 * @return {*}
 */
export function isCheckTimeOut() {
  //当前时间
  const currentTime = Date.now()
  //缓存时间
  const timeStamp = getTimeStamp()
  return currentTime - timeStamp > TOKEN_TIME_VALUE
}
